package com.itheima.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.constant.MessageConstant;
import com.itheima.health.entity.Result;
import com.itheima.health.service.ReportMemberService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/report")
public class ReportMemberController {
    @Reference
    ReportMemberService reportMemberService;
    @RequestMapping("/getMemberBySex")
    public Result getMemberBySex(){
        try {
            List<Map<String,Object>>list1=reportMemberService.getMemberBySex();
            return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS,list1);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.GET_MEMBER_NUMBER_REPORT_FAIL);
        }
    }
    @RequestMapping("/getMemberByAge")
    public Result getMemberByAge(){
        List<Map<String,Integer>> list2=reportMemberService.getMemberByAge();
        return new Result(true,MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS,list2);
    }
}
